home *** CD-ROM | disk | FTP | other *** search
- "$ Revision: 1.1 $"
- "Copyright 1990:
- Jecel Mattos de Assumpcao Jr.
- LSI - EPSUP, Sao Paulo, SP, Brasil"
-
- "Generic Simulation Objects "
-
- "traits simulation component"
- "<prototypes simulation> component"
- "Parts that actually do the work during the simulation"
-
- "<prototypes simulation> library"
- "Name space for standard components"
-
- "traits simulation net"
- "<prototypes simulation> net"
- "Connects Pins to each other"
-
- "traits simulation pin"
- "<prototypes simulation> pin"
- "Connects a Component to a Net"
-
- "<prototypes simulation> event"
- "Schedules a change of value at a Pin"
-
- "<prototypes simulation> wave"
- "Holds the waveform for a Pin"
-
- "<prototypes simulation> fsm"
- "Implements Finite State Machines"
-
- "traits simulation runTime"
- "<prototypes simulation> runTime"
- "Run Time simulation support"
-
- traits simulation _DefineSlots: ( |
- component = ( |
- cloning** = traits clonable.
- comparing** = mixins comparisons identity.
- fsm = ( prototypes simulation fsm copy ).
- part = ( self ).
- name = ( dad == nil ifTrue: [ ^ '' ]
- False: [ | dm. |
- dm: reflect: dad.
- dm size do: [ | :i |
- ( dm contentsAt: i ) isReflecteeMethod
- ifFalse: [
- == ( dm contentsAt: i ) reflectee ifTrue: [
- ^ dad name , ' ' , ( dm nameAt: i ) ].
- ( dm contentsAt: i ) isReflecteeVector ifTrue: [
- | v |
- v: ( dm contentsAt: i ) reflectee.
- v size do: [ | :j |
- == ( v at: j ) ifTrue: [
- ^ '(' , dad name , ' ' , ( dm nameAt:
- i ) , ' at: ' , j printString ,
- ' )' ].
- ].
- ].
- ].
- ].
- error: 'bad component hierarchy'.
- ].
- ).
- expandable = ( | m |
- m: reflect: self.
- m size do: [ | :i |
- ( ( m nameAt: i ) = 'netlist' ) ifTrue: [ ^ true ].
- ].
- false.
- ).
- executable = ( | m |
- m: reflect: self.
- m size do: [ | :i |
- ( ( m nameAt: i ) = 'behave' ) ifTrue: [ ^ true ].
- ].
- false.
- ).
- set: pin To: value After: time = ( | e. |
- e: event copy.
- e pin: pin.
- e value: value.
- schedule: e After: time.
- ).
- set: pin To: value = (
- set: pin To: value After: 0.
- ).
- simulate = (
- runTime copy getRoot: self.
- 'detailed simulation - type help for more information'
- ).
- exert = ( | s |
- s: runTime copy.
- s expandAll: false.
- s getRoot: self.
- 'high level simulation - type help for more information'
- ).
- askSim = ( | s |
- s: runTime copy.
- s expandAll: false.
- s askExpand: true.
- s getRoot: self.
- 'mixed level simulation - type help for more information'
- ).
- layout = ( 'NOT IMPLEMENTED YET !' ).
- | ).
- net = ( |
- copy = ( | n. |
- n: clone.
- n pins: pins copy.
- n.
- ).
- restart = ( | v. |
- v: pins oddballs simulation levels highImpedance.
- pins do: [ | :p. |
- v: p value resolve: v
- ].
- value: v
- ).
- reCheckFor: aSim = ( | v. |
- v: aSim z.
- pins do: [ | :p. |
- v: p value resolve: v
- ].
- value == v ifFalse: [
- value: v.
- pins do: [ | :p. |
- ( p input ) && ( p component leaf )
- ifTrue: [ aSim notify add: p component ].
- p wave == nil ifFalse: [ p wave become: v ].
- ].
- ].
- ).
- | ).
- simPin = ( |
- myName = ( | cm. |
- cm: reflect: component.
- cm size do: [ | :i |
- ( cm contentsAt: i ) isReflecteeMethod
- ifFalse: [
- == ( cm contentsAt: i ) reflectee
- ifTrue: [ ^ cm nameAt: i ].
- ].
- ].
- error: 'bad component'.
- ).
- printString = ( component name ,
- ' ' , myName ,
- ' --> ' ,
- net value printString ).
- to: aPin = (
- (net == aPin net)
- ifFalse: [ net pins addAll: aPin net pins.
- aPin net pins do: [ | :p |
- p net: net
- ].
- ].
- ).
- level = ( net value level ).
- not = ( net value not ).
- || aPin = ( ( net value ) || ( aPin net value ) ).
- && aPin = ( ( net value ) && ( aPin net value ) ).
- | ).
- runTime = ( |
- parent** = traits clonable.
- userCommands* = ( |
- restart = (
- now: 0.
- events: treeBag copy.
- pins do: [ | :p |
- ( p component leaf )
- ifTrue: [
- p restart.
- p net restart.
- ].
- ].
- ).
- step = (
- events isEmpty ifFalse: [
- notify: set copy.
- checkNets: set copy.
- now: events leftMost key.
- [ events isEmpty
- ifFalse: [ events leftMost key == now ]
- True: [ false ] ]
- whileTrue: [ | e. |
- e: events first.
- events remove: now.
- e pin value: e value.
- checkNets add: e pin net.
- ].
- checkNets do: [ | :n | n reCheckFor: self ].
- notify do: [ | :c | c behave ].
- ].
- now.
- ).
- stepBy: interval = (
- stepTo: now + interval.
- now.
- ).
- stepTo: time = (
- [ events isEmpty
- ifFalse: [ events leftMost key < time ]
- True: [ false ] ]
- whileTrue: [ step. ].
- now: time.
- now.
- ).
- run = ( [ events isEmpty ] whileFalse: [ step ]. now. ).
- watch: aPin = (
- wList add: aPin.
- aPin wave: prototypes simulation wave copy.
- aPin wave sim: sim.
- aPin wave become: aPin net value.
- aPin.
- ).
- watch = ( wList do: [ | :p | p printLine ]. 'watch pins' ).
- all = ( pins do: [ | :p | p printLine ]. 'all pins' ).
- draw = ( | g. sx. sy. k. |
- g: heightLimitedScreenBitmap copy.
- g initialize.
- g fillRectangle: 0 @ 0 To: 1000 @ 600 Color: colors white.
- g changeFont: 'screen.b.14'.
- sx: 200.
- sy: 20.
- k: 600 / wList size.
- wList do: [ | :p. t. |
- t: paragraph copyLines: p component name ,
- ' ' , p myName.
- g text: t At: 10 @ sy.
- p wave drawOn: g At: sx @ sy.
- sy: sy + k.
- ].
- 0 to: now By: 10 Do: [ | :time. x. |
- x: ( ( ( time - offset ) * scale ) + sx ).
- ( x < 980 ) && ( x >= sx ) ifTrue: [
- g text: ( paragraph copyLines: time printString )
- At: x @ 580.
- ].
- ].
- g release.
- ).
- help = ( '
-
- HELP mixed level digital event-driven simulator.
-
- user commands:
-
- restart - sets the simulation to the initial state
- step - simulate until something changes
- run - simulate until everything is stable
- stepTo: TIME - simulate until the specified TIME in ns
- stepBy: INTERVAL - simulate for specified INTERVAL ns
- watch: PIN - adds PIN to the watch list
- watch - show current values of pins in the watch list
- all - show current values of all pins
- draw - draw the waveforms of pins in the watch list
- help - prints this message
- ' ).
- | ).
- operation* = ( |
- schedule: anEvent After: interval = (
- schedule: anEvent At: now + interval.
- ).
- schedule: anEvent At: time = (
- events at: time Put: anEvent.
- ).
- | ).
- values* = ( |
- x = oddballs simulation levels unknown.
- l = oddballs simulation levels drivenLow.
- h = oddballs simulation levels drivenHigh.
- z = oddballs simulation levels highImpedance.
- | ).
- startUp* = ( |
- get: aPart = ( | c. |
- c: aPart copy.
- c sim: sim.
- c dad: part.
- c leaf: true.
- leaf: false.
- c declare.
- expandAll && c expandable ifTrue: [ c netlist. ].
- expandAll not && c executable not ifTrue: [ c netlist. ].
- askExpand && c expandable && c executable ifTrue: [
- | ask = ' ' copy. |
- 'Do you wish to expand ' print.
- c type print.
- ' ? ' print.
- 0 _ReadInto: ask Count: 10.
- ( 'Yy' includes: ( ask at: 0 ) ) ifTrue: [ c netlist ].
- ].
- c.
- ).
- sim = ( self ).
- part = ( nil ).
- leaf.
- getRoot: aPart = (
- simRoot: nil.
- pins: pins copy.
- wList: wList copy.
- notify: notify copy.
- events: events copy.
- root: ( get: aPart ).
- simRoot: root.
- ).
- vdd = ( | p. |
- vddg == nil ifFalse: [ vddg ]
- True: [
- p: supply copy.
- p component: root.
- p net: prototypes net copy.
- p net pins add: p.
- vddg: p.
- p.
- ].
- ).
- gnd = ( | p. |
- gndg == nil ifFalse: [ gndg ]
- True: [
- p: ground copy.
- p component: root.
- p net: prototypes net copy.
- p net pins add: p.
- gndg: p.
- p.
- ].
- ).
- output = ( | p. |
- p: outPin copy.
- p component: self.
- p value: z.
- p net: prototypes net copy.
- p net pins add: p.
- pins add: p.
- p.
- ).
- input = ( | p. |
- p: inPin copy.
- p component: self.
- p value: z.
- p net: prototypes net copy.
- p net pins add: p.
- pins add: p.
- p.
- ).
- | ).
- | ).
- | )
-
- prototypes simulation _DefineSlots: ( |
- component = ( |
- parent* = traits simulation component.
- sim**.
- dad.
- leaf.
- type = 'prototypical circuit'.
- declare = ().
- behave = ().
- | ).
- library = ().
- | )
-
- prototypes simulation _DefineSlots: ( |
- net = ( |
- parent* = traits simulation net.
- cloning** = traits clonable.
- comparing*** = mixins comparisons identity.
- value.
- pins <- set copy.
- | ).
- event = ( |
- parent* = traits clonable.
- thisObjectPrints = true.
- printString = ( pin printString , '->' , value printString ).
- value.
- pin.
- | ).
- wave = ( |
- parent* = traits clonable.
- sim.
- values.
- times.
- copy = ( | c. |
- c: clone.
- c values: list copy.
- c times: list copy.
- c.
- ).
- become: aValue = (
- values add: aValue.
- times add: sim now.
- ).
- drawOn: bitmap At: point = ( | x1. x2. signal. |
- signal: sim z.
- x2: point x - 30.
- times with: values Do: [ | :t. :v. |
- x1: x2.
- x2: ( ( ( t - sim offset ) * sim scale ) + point x ).
- x2: ( ( 980 min: x2 ) max: point x ).
- signal drawOn: bitmap From: x1 @ point y
- To: x2 @ ( point y + 20 ).
- signal: v.
- ].
- signal drawOn: bitmap From: x2 @ point y
- To: 980 @ ( point y + 20 ).
- ).
- | ).
- fsm = ( |
- parent** = traits clonable.
- state <- ''.
- next <- ''.
- lastSignal.
- initial: text = (
- state: text.
- next: text.
- lastSignal: nil.
- ).
- onRising: pin Is: action = (
- ( rising: pin net value ) ifTrue: [
- fsmRoot: self.
- action value.
- fsmRoot: ().
- ].
- ).
- onFalling: pin Is: action = (
- ( falling: pin net value ) ifTrue: [
- fsmRoot: self.
- action value.
- fsmRoot: ().
- ].
- ).
- state: text Do: things = (
- text = state ifTrue: [ things value ].
- ).
- goto: text = ( next: text ).
- rising: signal = (
- state: next.
- signal isHigh
- ifTrue: [
- lastSignal isHigh ifTrue: [ ^ false ].
- lastSignal: signal.
- ^ true.
- ].
- lastSignal: signal.
- false.
- ).
- falling: signal = (
- state: next.
- signal isLow
- ifTrue: [
- lastSignal isLow ifTrue: [ ^ false ].
- lastSignal: signal.
- ^ true.
- ].
- lastSignal: signal.
- false.
- ).
- | ).
- runTime = ( |
- parent* = traits simulation runTime.
- now <- 0.
- expandAll <- true.
- askExpand <- false.
- events <- treeBag copy.
- notify <- set copy.
- checkNets <- set copy.
- pins <- set copy.
- wList <- list copy.
- offset <- 0.
- scale <- 5.
- vddg.
- gndg.
- root <- prototypes simulation component.
- supply = ( |
- parent* = traits simulation simPin.
- cloning** = traits clonable.
- comparing** = mixins comparisons identity.
- thisObjectPrints = true.
- printString = 'vdd'.
- component <- prototypes simulation component.
- value = oddballs simulation levels drivenHigh.
- net <- nil.
- input = false.
- wave.
- restart = ().
- | ).
- ground = ( |
- parent* = traits simulation simPin.
- cloning** = traits clonable.
- comparing** = mixins comparisons identity.
- thisObjectPrints = true.
- printString = 'gnd'.
- component <- prototypes simulation component.
- value = oddballs simulation levels drivenLow.
- net <- nil.
- input = false.
- wave.
- restart = ().
- | ).
- outPin = ( |
- parent* = traits simulation simPin.
- cloning** = traits clonable.
- comparing** = mixins comparisons identity.
- thisObjectPrints = true.
- component <- prototypes simulation component.
- value.
- net <- nil.
- input = false.
- wave.
- restart = ( value: oddballs simulation levels unknown ).
- | ).
- inPin = ( |
- parent* = traits simulation simPin.
- cloning** = traits clonable.
- comparing** = mixins comparisons identity.
- thisObjectPrints = true.
- component <- prototypes simulation component.
- value.
- net <- nil.
- input = true.
- wave.
- restart = ( value: oddballs simulation levels highImpedance ).
- | ).
- | ).
- simRoot** <- ().
- fsmRoot*** <- ().
- | )
-